﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CKY_Parsing_Algorithm
{
    public partial class Form1 : Form
    {
        #region Initialization
        public Form1()
        {
            InitializeComponent();
            this.StartPosition = FormStartPosition.CenterScreen;
            this.MaximizeBox = false;
            wbbExecute.IsWebBrowserContextMenuEnabled = false;            
            cbbChooseSentence.Items.Add(c1);
            cbbChooseSentence.Items.Add(c2);
            cbbChooseSentence.Items.Add(c3);
            cbbChooseSentence.SelectedItem = cbbChooseSentence.Items[0];
            btnRun_Click(null, null);
        }
        #endregion

        #region Variable Declaration
        string c1 = "The chef eats fish with the chopsticks";
        string c2 = "I saw the man with the gun";
        string c3 = "New Sentence...";
        #endregion

        #region Event
        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string s1 = "Đại Học Công Nghệ Thông Tin - ĐHQG TP.HCM.\n";
            string s2 = "Giảng viên: TS. Nguyễn Tuấn Đăng \n";
            string s3 = "Sinh Viên: Lâm Thanh Cường - 08520526\n";
            string s4 = "                   Huỳnh Ngọc Khuê - 08520557 \n";
            string s5 = "About: CKY Parsing Demo";
            MessageBox.Show(s1 + s2 + s3 + s4, s5, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        private void btnRun_Click(object sender, EventArgs e)
        {            
            wbbExecute.ScrollBarsEnabled = false;
            try
            {
                if (cbbChooseSentence.SelectedItem == cbbChooseSentence.Items[0])
                {
                    wbbExecute.Url = new Uri("file:///" + Application.StartupPath + "/Data/CKY Demo 1.cky");
                }
                if (cbbChooseSentence.SelectedItem == cbbChooseSentence.Items[1])
                {
                    wbbExecute.Url = new Uri("file:///" + Application.StartupPath + "/Data/CKY Demo 2.cky");
                }
                if (cbbChooseSentence.SelectedItem == cbbChooseSentence.Items[2])
                {
                    wbbExecute.Url = new Uri("file:///" + Application.StartupPath + "/Data/CKY Demo New.cky");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi chưa nhập cú pháp hoặc câu..." + ex.Message, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                wbbExecute.Url = new Uri("file:///" + Application.StartupPath + "/Data/CKY Demo New.cky");
            }
        }
        private void newSentenceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                cbbChooseSentence.SelectedItem = cbbChooseSentence.Items[2];
                wbbExecute.Url = new Uri("file:///" + Application.StartupPath + "/Data/CKY Demo New.cky");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi chưa nhập cú pháp hoặc câu..." + ex.Message, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                wbbExecute.Url = new Uri("file:///" + Application.StartupPath + "/Data/CKY Demo New.cky");
            }
        }
        private void btnNewSentence_Click(object sender, EventArgs e)
        {
            newSentenceToolStripMenuItem_Click(null, null);
        }
        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        #endregion      
    }
}
